package com.youyi.yyfilepickerlibrary.core.task;

import android.os.AsyncTask;
import com.youyi.yyfilepickerlibrary.core.model.EssFile;
import com.youyi.yyfilepickerlibrary.core.model.EssFileCountCallBack;
import com.youyi.yyfilepickerlibrary.core.model.EssFileFilter;
import java.io.File;
import java.util.Arrays;

public class EssFileCountTask extends AsyncTask<Void, Void, Void> {
    private int childFileCount = 0;
    private int childFolderCount = 0;
    private EssFileCountCallBack countCallBack;
    private int position;
    private String queryPath;
    private String[] types;

    public EssFileCountTask(int i, String str, String[] strArr, EssFileCountCallBack essFileCountCallBack) {
        this.position = i;
        this.queryPath = str;
        this.types = strArr;
        this.countCallBack = essFileCountCallBack;
    }

    /* access modifiers changed from: protected */
    public Void doInBackground(Void... voidArr) {
        File[] listFiles = new File(this.queryPath).listFiles(new EssFileFilter(this.types));
        if (listFiles == null) {
            return null;
        }
        for (EssFile essFile : EssFile.getEssFileList(Arrays.asList(listFiles))) {
            if (essFile.isDirectory()) {
                this.childFolderCount++;
            } else {
                this.childFileCount++;
            }
        }
        return null;
    }

    /* access modifiers changed from: protected */
    public void onPostExecute(Void r4) {
        EssFileCountCallBack essFileCountCallBack = this.countCallBack;
        if (essFileCountCallBack != null) {
            essFileCountCallBack.onFindChildFileAndFolderCount(this.position, String.valueOf(this.childFileCount), String.valueOf(this.childFolderCount));
        }
    }
}
